package com.hx.netty.chat.protocol;

import lombok.*;
import org.msgpack.annotation.Message;

/**
 * @author Huathy
 * @date 2021-10-24 22:06
 * @description 消息对象：Java自定义传播协议的消息体。
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
//消息体 注解。
@Message
public class ImMsg {
    /** IP地址及端口 */
    private String addr;
    /** 命令类型IMP */
    private String cmd;
    /** 时间 */
    private long time;
    /** 在线人数 */
    private int online;
    /** 发送者 */
    private String sender;
    /** 接收者 */
    private String receiver;
    /** 消息内容 */
    private String content;
    /** 终端 */
    private String terminal;

    public ImMsg(String cmd,long time,int online,String content){
        this.cmd = cmd;
        this.time = time;
        this.online = online;
        this.content = content;
        this.terminal = terminal;
    }

    public ImMsg(String cmd,String terminal,long time,String sender){
        this.cmd = cmd;
        this.time = time;
        this.sender = sender;
        this.terminal = terminal;
    }


    public ImMsg(String cmd,long time,String sender,String content){
        this.cmd = cmd;
        this.time = time;
        this.sender = sender;
        this.content = content;
        this.terminal = terminal;
    }
}
